/**
* @author AlbertDarren
* @contact 2563491540@qq.com
*/
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <list>
using namespace std;
void show(auto &container)
{
    for(auto element:container)
    {
        cout << element << " ";
    }
    cout << endl;
}
void find_first_all(auto &container,auto &target)
{
    auto iter=find_first_of(container.begin(),container.end(),target.begin(),target.end());
    if (iter!=container.end())
    {
        do
        {
            cout << "find "<<*iter<<" of target at "<<distance(container.begin(),iter) << endl;
            ++iter;
        }
        while ((iter=find_first_of(iter,container.end(),target.begin(),target.end()))!=container.end());
    }
    else
    {
        cout << "Don't find anyone of target in the container" << endl;
    }
}
void find_last_all(auto &container,auto &target)
{
    auto iter=find_first_of(container.rbegin(),container.rend(),target.begin(),target.end());
    if (iter!=container.rend())
    {
        do
        {
//            cout << "find "<<*iter<<" of target at "<<distance(container.begin(),iter.base())-1<< endl;
            cout << "find "<<*iter<<" of target at "<<distance(iter,container.rend())-1<< endl;
            ++iter;
        }
        while ((iter=find_first_of(iter,container.rend(),target.begin(),target.end()))!=container.rend());
    }
    else
    {
        cout << "Don't find anyone of target in the container" << endl;
    }
}
int main_30()
{
    std::ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    srand((unsigned int)time(nullptr));
    vector<int> int_vect;
    list<int> int_list;
    int random_int;
    for (int i=0; i<20 ; ++i )
    {
        random_int=rand()%20;
        int_vect.push_back(random_int);
    }
    for (int i=0; i<3 ; ++i )
    {
        random_int=rand()%20;
        int_list.push_back(random_int);
    }
    show(int_vect);
    show(int_list);
    find_first_all(int_vect,int_list);
    cout << "reverse_iterator" << endl;
    find_last_all(int_vect,int_list);
    return 0;
}
